package view;

import java.applet.Applet;
import java.applet.AudioClip;
import java.util.HashMap;

public class SoundLoader {
	
	private HashMap<String, AudioClip> sounds;
	
	public SoundLoader(String sound_path){
		
		sounds = new HashMap<String, AudioClip>();
				
				
		try{
			sounds.put("background", Applet.newAudioClip(this.getClass().getResource(sound_path+"background.WAV")) );
			sounds.put("dead", Applet.newAudioClip(this.getClass().getResource(sound_path+"dead.WAV")) );
			sounds.put("won", Applet.newAudioClip(this.getClass().getResource(sound_path+"won.WAV")) );
			sounds.put("game_over", Applet.newAudioClip(this.getClass().getResource(sound_path+"game_over.WAV")) );
			sounds.put("jump", Applet.newAudioClip(this.getClass().getResource(sound_path+"jump.WAV")) );
			//sounds.put("na", Applet.newAudioClip(this.getClass().getResource(sound_path+"na.wav")) );
			
		} catch (Exception ex){
			ex.printStackTrace();
		} 
	}
	
	public void play(String name){

		AudioClip sound = sounds.get(name);
		
		if(sound == null){
			//sounds.get("na").play();
		}else{
			sound.play();
			//sound.loop();
		}

	}
}
